# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[_wyclock = peewee_dbus.reference('com.wyplay.wycrs', '/com/wyplay/wycrs/wyclock', 'com.wyplay.wycrs')
self._set_time_setter = _wyclock.method('SetTimeSetter', 'i', '')
self._get_time_setter = _wyclock.method('GetTimeSetter', '', 'i')
self.set_time_signal = peewee_dbus.signal('/com/wyplay/peewee', 'SetTime', 'x')
self._timezones = []
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb77036ec>}
nname: 0
n 0(None)[return self._set_time_setter(time)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7701eec>}
nname: 0
n 0(None)[return self._set_time_setter(time)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7701f2c>}
nname: 0
n 0(None)[return self._get_time_setter()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7701e8c>}
nname: 0
n 0(None)[return self._get_time_setter()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7701eec>}
nname: 0
n 0(None)[self._timezones = []
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7701dac>}
nname: 0
n 0(None)[self.set_time_signal(time)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb7701e8c>}
nname: 157
n 157(None)[f.close()
self._timezones.sort()
return self._timezones
]:
	i: 80(AL), 156()
	o: 

nname: 156
n 156(None)[]:
	i: 83(AF), 133()
	o: 157()

nname: 133
n 133(None)[self._timezones.append(_array[2])
]:
	i: 125(), 132()
	o: 156()

nname: 132
n 132(None)[]:
	i: 90(f)
	o: 133()

nname: 125
n 125(None)[continue
]:
	i: 90(t)
	o: 133()

nname: 90
n 90(_array[0][0] in ('#',))[for _f in f:
_array = _f.split()
]:
	i: 83(for)
	o: 125(t), 132(f)

nname: 83
n 83(None)[]:
	i: 80(loop)
	o: 90(for), 156(AF)

nname: 80
n 80(None)[]:
	i: 24(), 65(), 78(AE)
	o: 83(loop), 157(AL)

nname: 78
n 78(None)[]:
	i: 55(f)
	o: 80(AE)

nname: 65
n 65(None)[#, e
return []
]:
	i: 55(t)
	o: 80()

nname: 55
n 55(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 21(except)
	o: 65(t), 78(f)

nname: 24
n 24(None)[f = open(os.path.join(zoneinfo_dir, 'zone.tab'))
]:
	i: 21(try)
	o: 80()

nname: 21
n 21(None)[]:
	i: 9(), 20()
	o: 24(try), 55(except)

nname: 20
n 20(None)[]:
	i: 0(f)
	o: 21()

nname: 9
n 9(None)[return self._timezones
]:
	i: 0(t)
	o: 21()

nname: 0
n 0(self._timezones)[]:
	i: 
	o: 9(t), 20(f)

nname: 157
n 157(None)[f.close()
self._timezones.sort()
return self._timezones
]:
	i: 80(AL), 83(AF), 90()
	o: 

nname: 90
n 90(None)[for _f in f:
_array = _f.split()
if _array[0][0] in ('#',):
	continue
self._timezones.append(_array[2])
]:
	i: 83(for)
	o: 157()

nname: 83
n 83(None)[]:
	i: 80(loop)
	o: 90(for), 157(AF)

nname: 80
n 80(None)[]:
	i: 24()
	o: 83(loop), 157(AL)

nname: 24
n 24(None)[try:
	f = open(os.path.join(zoneinfo_dir, 'zone.tab'))
except Exception, e:
	return []
]:
	i: 0(try)
	o: 80()

nname: 0
n 0(None)[if self._timezones:
	return self._timezones
]:
	i: 
	o: 24(try)

nname: 90
n 90(None)[for _f in f:
	_array = _f.split()
	if _array[0][0] in ('#',):
		continue
	self._timezones.append(_array[2])
f.close()
self._timezones.sort()
return self._timezones
]:
	i: 80(for)
	o: 

nname: 80
n 80(None)[]:
	i: 0()
	o: 90(for)

nname: 0
n 0(None)[if self._timezones:
	return self._timezones
try:
	f = open(os.path.join(zoneinfo_dir, 'zone.tab'))
except Exception, e:
	return []
]:
	i: 
	o: 80()

nname: 90
n 90(None)[for _f in f:
	_array = _f.split()
	if _array[0][0] in ('#',):
		continue
	self._timezones.append(_array[2])
f.close()
self._timezones.sort()
return self._timezones
]:
	i: 0(for)
	o: 

nname: 0
n 0(None)[if self._timezones:
	return self._timezones
try:
	f = open(os.path.join(zoneinfo_dir, 'zone.tab'))
except Exception, e:
	return []
]:
	i: 
	o: 90(for)

nname: 0
n 0(None)[if self._timezones:
	return self._timezones
try:
	f = open(os.path.join(zoneinfo_dir, 'zone.tab'))
except Exception, e:
	return []
for _f in f:
	_array = _f.split()
	if _array[0][0] in ('#',):
		continue
	self._timezones.append(_array[2])
f.close()
self._timezones.sort()
return self._timezones
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb770c16c>}
nname: 128
n 128(None)[]:
	i: 38(), 112(), 126(AE)
	o: 

nname: 126
n 126(None)[]:
	i: 102(f)
	o: 128(AE)

nname: 112
n 112(None)[PRINT_EXCEPTION()
]:
	i: 102(t)
	o: 128()

nname: 102
n 102(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 35(except)
	o: 112(t), 126(f)

nname: 38
n 38(None)[os.unlink(localtime_path)
os.symlink(os.path.join('/usr/share/zoneinfo', timezone), localtime_path)
os.putenv('TZ', timezone)
]:
	i: 35(try)
	o: 128()

nname: 35
n 35(None)[]:
	i: 24(), 34()
	o: 38(try), 102(except)

nname: 34
n 34(None)[]:
	i: 0(f)
	o: 35()

nname: 24
n 24(None)[localtime_path = localtime_redist_path
]:
	i: 0(t)
	o: 35()

nname: 0
n 0(os.path.lexists(localtime_redist_path))[localtime_path = localtime_normal_path
]:
	i: 
	o: 24(t), 34(f)

nname: 128
n 128(None)[]:
	i: 38()
	o: 

nname: 38
n 38(None)[try:
	os.unlink(localtime_path)
	os.symlink(os.path.join('/usr/share/zoneinfo', timezone), localtime_path)
	os.putenv('TZ', timezone)
except Exception:
	PRINT_EXCEPTION()
]:
	i: 0(try)
	o: 128()

nname: 0
n 0(None)[localtime_path = localtime_normal_path
if os.path.lexists(localtime_redist_path):
	localtime_path = localtime_redist_path
]:
	i: 
	o: 38(try)

nname: 128
n 128(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[localtime_path = localtime_normal_path
if os.path.lexists(localtime_redist_path):
	localtime_path = localtime_redist_path
try:
	os.unlink(localtime_path)
	os.symlink(os.path.join('/usr/share/zoneinfo', timezone), localtime_path)
	os.putenv('TZ', timezone)
except Exception:
	PRINT_EXCEPTION()
]:
	i: 
	o: 128()

nname: 0
n 0(None)[localtime_path = localtime_normal_path
if os.path.lexists(localtime_redist_path):
	localtime_path = localtime_redist_path
try:
	os.unlink(localtime_path)
	os.symlink(os.path.join('/usr/share/zoneinfo', timezone), localtime_path)
	os.putenv('TZ', timezone)
except Exception:
	PRINT_EXCEPTION()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb770cfcc>}
nname: 6
n 6(None)[__metaclass__ = MetaSingleton
def __init__(self):
	_wyclock = peewee_dbus.reference('com.wyplay.wycrs', '/com/wyplay/wycrs/wyclock', 'com.wyplay.wycrs')
	self._set_time_setter = _wyclock.method('SetTimeSetter', 'i', '')
	self._get_time_setter = _wyclock.method('GetTimeSetter', '', 'i')
	self.set_time_signal = peewee_dbus.signal('/com/wyplay/peewee', 'SetTime', 'x')
	self._timezones = []

time_setter = property((lambda self: self._get_time_setter()), (lambda self, time: self._set_time_setter(time)))
def reset(self):
	self._timezones = []

def set_time(self, time):
	self.set_time_signal(time)

def get_timezones(self):
	if self._timezones:
		return self._timezones
	try:
		f = open(os.path.join(zoneinfo_dir, 'zone.tab'))
	except Exception, e:
		return []
	for _f in f:
		_array = _f.split()
		if _array[0][0] in ('#',):
			continue
		self._timezones.append(_array[2])
	f.close()
	self._timezones.sort()
	return self._timezones

def set_timezone(self, timezone):
	localtime_path = localtime_normal_path
	if os.path.lexists(localtime_redist_path):
		localtime_path = localtime_redist_path
	try:
		os.unlink(localtime_path)
		os.symlink(os.path.join('/usr/share/zoneinfo', timezone), localtime_path)
		os.putenv('TZ', timezone)
	except Exception:
		PRINT_EXCEPTION()

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb7701b4c>}
nname: 0
n 0(None)[from __future__ import absolute_import
import os
from .debug import PRINT_EXCEPTION
from .dbus import peewee_dbus
from .misc_utils import MetaSingleton
__all__ = ['TimeManager']
localtime_redist_path = '/etc/params/localtime'
localtime_normal_path = '/etc/localtime'
timezone = []
zoneinfo_dir = '/usr/share/zoneinfo/'
WYCLOCK_MANUAL_SETTER = 1
WYCLOCK_AUTO_SETTER = 3
class TimeManager(object):
	__metaclass__ = MetaSingleton
	def __init__(self):
		_wyclock = peewee_dbus.reference('com.wyplay.wycrs', '/com/wyplay/wycrs/wyclock', 'com.wyplay.wycrs')
		self._set_time_setter = _wyclock.method('SetTimeSetter', 'i', '')
		self._get_time_setter = _wyclock.method('GetTimeSetter', '', 'i')
		self.set_time_signal = peewee_dbus.signal('/com/wyplay/peewee', 'SetTime', 'x')
		self._timezones = []

	time_setter = property((lambda self: self._get_time_setter()), (lambda self, time: self._set_time_setter(time)))
	def reset(self):
		self._timezones = []

	def set_time(self, time):
		self.set_time_signal(time)

	def get_timezones(self):
		if self._timezones:
			return self._timezones
		try:
			f = open(os.path.join(zoneinfo_dir, 'zone.tab'))
		except Exception, e:
			return []
		for _f in f:
			_array = _f.split()
			if _array[0][0] in ('#',):
				continue
			self._timezones.append(_array[2])
		f.close()
		self._timezones.sort()
		return self._timezones

	def set_timezone(self, timezone):
		localtime_path = localtime_normal_path
		if os.path.lexists(localtime_redist_path):
			localtime_path = localtime_redist_path
		try:
			os.unlink(localtime_path)
			os.symlink(os.path.join('/usr/share/zoneinfo', timezone), localtime_path)
			os.putenv('TZ', timezone)
		except Exception:
			PRINT_EXCEPTION()



]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76f7b4c>}
from __future__ import absolute_import
import os
from .debug import PRINT_EXCEPTION
from .dbus import peewee_dbus
from .misc_utils import MetaSingleton
__all__ = ['TimeManager']
localtime_redist_path = '/etc/params/localtime'
localtime_normal_path = '/etc/localtime'
timezone = []
zoneinfo_dir = '/usr/share/zoneinfo/'
WYCLOCK_MANUAL_SETTER = 1
WYCLOCK_AUTO_SETTER = 3
class TimeManager(object):
	__metaclass__ = MetaSingleton
	def __init__(self):
		_wyclock = peewee_dbus.reference('com.wyplay.wycrs', '/com/wyplay/wycrs/wyclock', 'com.wyplay.wycrs')
		self._set_time_setter = _wyclock.method('SetTimeSetter', 'i', '')
		self._get_time_setter = _wyclock.method('GetTimeSetter', '', 'i')
		self.set_time_signal = peewee_dbus.signal('/com/wyplay/peewee', 'SetTime', 'x')
		self._timezones = []

	time_setter = property((lambda self: self._get_time_setter()), (lambda self, time: self._set_time_setter(time)))
	def reset(self):
		self._timezones = []

	def set_time(self, time):
		self.set_time_signal(time)

	def get_timezones(self):
		if self._timezones:
			return self._timezones
		try:
			f = open(os.path.join(zoneinfo_dir, 'zone.tab'))
		except Exception, e:
			return []
		for _f in f:
			_array = _f.split()
			if _array[0][0] in ('#',):
				continue
			self._timezones.append(_array[2])
		f.close()
		self._timezones.sort()
		return self._timezones

	def set_timezone(self, timezone):
		localtime_path = localtime_normal_path
		if os.path.lexists(localtime_redist_path):
			localtime_path = localtime_redist_path
		try:
			os.unlink(localtime_path)
			os.symlink(os.path.join('/usr/share/zoneinfo', timezone), localtime_path)
			os.putenv('TZ', timezone)
		except Exception:
			PRINT_EXCEPTION()



